package com.ruoyi.procurementmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.procurementmanagement.domain.EsPurOrder;
import com.ruoyi.procurementmanagement.service.IEsPurOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购订单跟踪表Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/procurementmanagement/purorder")
public class EsPurOrderController extends BaseController
{
    @Autowired
    private IEsPurOrderService esPurOrderService;

    /**
     * 查询采购订单跟踪表列表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(EsPurOrder esPurOrder)
    {
        startPage();
        List<EsPurOrder> list = esPurOrderService.selectEsPurOrderList(esPurOrder);
        return getDataTable(list);
    }

    /**
     * 导出采购订单跟踪表列表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:export')")
    @Log(title = "采购订单跟踪表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EsPurOrder esPurOrder)
    {
        List<EsPurOrder> list = esPurOrderService.selectEsPurOrderList(esPurOrder);
        ExcelUtil<EsPurOrder> util = new ExcelUtil<EsPurOrder>(EsPurOrder.class);
        util.exportExcel(response, list, "采购订单跟踪表数据");
    }

    /**
     * 获取采购订单跟踪表详细信息
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(esPurOrderService.selectEsPurOrderByOrderId(orderId));
    }

    /**
     * 新增采购订单跟踪表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:add')")
    @Log(title = "采购订单跟踪表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EsPurOrder esPurOrder)
    {
        return toAjax(esPurOrderService.insertEsPurOrder(esPurOrder));
    }

    /**
     * 修改采购订单跟踪表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:edit')")
    @Log(title = "采购订单跟踪表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EsPurOrder esPurOrder)
    {
        return toAjax(esPurOrderService.updateEsPurOrder(esPurOrder));
    }

    /**
     * 删除采购订单跟踪表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:purorder:remove')")
    @Log(title = "采购订单跟踪表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(esPurOrderService.deleteEsPurOrderByOrderIds(orderIds));
    }
}
